Conda environments
Create or refresh an environment
We call our environment std
, for ‘standard’.
If an environment of this name exists, make sure it is not activated, and then delete or rename the old environment directory (
~/.conda/envs/std/
).Make sure
~/.condarc
looks like this:channels: - conda-forge - defaults channel_priority: strict
This way, packages from
conda-forge
are accessible and have priority.Create and activate the new environment.
conda create -n std conda activate std
Install the Python interpreter and the IPython Kernel.
conda install python conda install ipykernel
VS Code tends to remember old environments. To refresh the information, disable the Python extension (and its dependencies, e.g. Pylance), reload VS Code, enable the Python extension et al., and reload. Then let VS Code install what it needs.
Install further packages as needed.
Record the state of an environment
The explicitly installed packages (conda install
or by VS Code) can be recorded by
conda env export --from-history > std.yml
Recreate an environment from the recorded state
With the file std.yml
, the same environment can be recreated somewhere else, follwing steps 1 and 2 and then using
conda env create -f std.yml
Update an environment to a recorded state
If the environment exists, it can also updated using
conda env update --name std --prune --file std.yml